home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / wc_PushB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  7.6 KB  |  187 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         wc_PushB.c
  5. * RCS:          $Header: wc_PushB.c,v 1.3 91/03/14 03:14:57 mayer Exp $
  6. * Description:  XM_PUSH_BUTTON_WIDGET_CLASS/XM_PUSH_BUTTON_GADGET_CLASS
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Sat Oct 28 04:22:22 1989
  9. * Modified:     Thu Oct  3 23:40:32 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. *
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: wc_PushB.c,v 1.3 91/03/14 03:14:57 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <Xm/Xm.h>
  45. #include <Xm/PushB.h>
  46. #include <Xm/PushBG.h>
  47. #include "winterp.h"
  48. #include "user_prefs.h"
  49. #include "xlisp/xlisp.h"
  50. #include "w_funtab.h"
  51.  
  52.  
  53. #ifdef WINTERP_MOTIF_11
  54. /******************************************************************************
  55.  * typedef struct
  56.  * {
  57.  *     int     reason;
  58.  *     XEvent  *event;
  59.  *     int        click_count;
  60.  * } XmPushButtonCallbackStruct;
  61.  ******************************************************************************/
  62. static void Lexical_Bindings_For_XmPushButtonCallbackStruct(bindings_list, lexical_env, cd, o_widget)
  63.      LVAL bindings_list;    /* a list of symbols to which values from XmPushButtonCallbackStruct are bound */
  64.      LVAL lexical_env;        
  65.      XmPushButtonCallbackStruct* cd;
  66.      LVAL o_widget;        /* XLTYPE_WIDGETOBJ */
  67. {
  68.   extern LVAL s_CALLBACK_WIDGET, s_CALLBACK_REASON, s_CALLBACK_XEVENT, s_CALLBACK_CLICK_COUNT; /* w_callbacks.c */
  69.   extern LVAL Wcb_Get_Callback_Reason_Symbol();    /* w_callbacks.c */
  70.   register LVAL s_bindname;
  71.  
  72.   for ( ; consp(bindings_list); bindings_list = cdr(bindings_list)) {
  73.  
  74.     s_bindname = car(bindings_list);
  75.  
  76.     if (s_bindname == s_CALLBACK_WIDGET) {
  77.       xlpbind(s_bindname, o_widget, lexical_env);
  78.     }
  79.     else if (s_bindname == s_CALLBACK_REASON) {
  80.       xlpbind(s_bindname, Wcb_Get_Callback_Reason_Symbol(cd->reason), lexical_env);
  81.     }
  82.     else if (s_bindname == s_CALLBACK_XEVENT) {
  83.       xlpbind(s_bindname, (cd->event) ? cv_xevent(cd->event) : NIL, lexical_env);
  84.     }
  85.     else if (s_bindname == s_CALLBACK_CLICK_COUNT) {
  86.       xlpbind(s_bindname, cvfixnum((FIXTYPE) (cd->click_count)), lexical_env);
  87.     }
  88.     else {
  89.       extern char temptext[];    /* from winterp.c */
  90.       sprintf(temptext,
  91.           "Unknown binding name in XmPushButtonCallbackStruct callback evaluator. Valid symbols are [%s %s %s %s].",
  92.           (char*) getstring(getpname(s_CALLBACK_WIDGET)),
  93.           (char*) getstring(getpname(s_CALLBACK_REASON)),
  94.           (char*) getstring(getpname(s_CALLBACK_XEVENT)),
  95.           (char*) getstring(getpname(s_CALLBACK_CLICK_COUNT)));
  96.       xlerror(temptext, s_bindname);
  97.     }
  98.   }
  99. }
  100.  
  101. /******************************************************************************
  102.  * This is called indirectly via XtAddCallback() for callbacks returning
  103.  * an XmPushButtonCallbackStruct as call_data.
  104.  ******************************************************************************/
  105. static void XmPushButtonCallbackStruct_Callbackproc(widget, client_data, call_data)
  106.      Widget    widget;
  107.      XtPointer client_data;
  108.      XtPointer call_data;
  109. {
  110.   extern void Wcb_Meta_Callbackproc(); /* w_callbacks.c */
  111.  
  112.   Wcb_Meta_Callbackproc(client_data, call_data,
  113.             Lexical_Bindings_For_XmPushButtonCallbackStruct,
  114.             NULL);
  115. }
  116.  
  117. /******************************************************************************
  118.  * Same as WIDGET_CLASS's :add_callback method except that this understands
  119.  * how to get values from the XmPushButtonCallbackStruct.
  120.  * Specifying one or more of the following symbols in the callback bindings 
  121.  * list will bind that symbol's value in the lexical environment of the callback:
  122.  * CALLBACK_WIDGET
  123.  * CALLBACK_REASON
  124.  * CALLBACK_XEVENT
  125.  * CALLBACK_CLICK_COUNT -- new for motif 1.1
  126.  ******************************************************************************/
  127. LVAL Xm_Push_Button_Widget_Class_Method_ADD_CALLBACK()
  128. {
  129.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  130.   return (Wcb_Meta_Method_Add_Callback(XmPushButtonCallbackStruct_Callbackproc, FALSE));
  131. }
  132.  
  133. /******************************************************************************
  134.  * Same as WIDGET_CLASS's :set_callback method except that this understands
  135.  * how to get values from the XmPushButtonCallbackStruct.
  136.  * Specifying one or more of the following symbols in the callback bindings 
  137.  * list will bind that symbol's value in the lexical environment of the callback:
  138.  * CALLBACK_WIDGET
  139.  * CALLBACK_REASON
  140.  * CALLBACK_XEVENT
  141.  * CALLBACK_CLICK_COUNT -- new for motif 1.1
  142.  ******************************************************************************/
  143. LVAL Xm_Push_Button_Widget_Class_Method_SET_CALLBACK()
  144. {
  145.   extern LVAL Wcb_Meta_Method_Add_Callback(); /* w_callbacks.c */
  146.   return (Wcb_Meta_Method_Add_Callback(XmPushButtonCallbackStruct_Callbackproc, TRUE));
  147. }
  148. #endif                /* WINTERP_MOTIF_11 */
  149.  
  150.  
  151. /******************************************************************************
  152.  *
  153.  ******************************************************************************/
  154. Wc_PushB_Init()
  155. {
  156.   LVAL o_XM_PUSH_BUTTON_WIDGET_CLASS;
  157.   LVAL o_XM_PUSH_BUTTON_GADGET_CLASS;
  158.   extern LVAL Wcls_Create_Subclass_Of_WIDGET_CLASS(); /* w_classes.c */
  159.   extern      xladdmsg();    /* from xlobj.c */
  160.  
  161.   o_XM_PUSH_BUTTON_WIDGET_CLASS =
  162.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_PUSH_BUTTON_WIDGET_CLASS",
  163.                      xmPushButtonWidgetClass);
  164.  
  165. #ifdef WINTERP_MOTIF_11
  166.   xladdmsg(o_XM_PUSH_BUTTON_WIDGET_CLASS, ":ADD_CALLBACK",
  167.            FTAB_Xm_Push_Button_Widget_Class_Method_ADD_CALLBACK);
  168.  
  169.   xladdmsg(o_XM_PUSH_BUTTON_WIDGET_CLASS, ":SET_CALLBACK",
  170.            FTAB_Xm_Push_Button_Widget_Class_Method_SET_CALLBACK);
  171. #endif                /* WINTERP_MOTIF_11 */
  172.  
  173.   o_XM_PUSH_BUTTON_GADGET_CLASS =
  174.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_PUSH_BUTTON_GADGET_CLASS",
  175.                      xmPushButtonGadgetClass);
  176.  
  177. #ifdef WINTERP_MOTIF_11
  178.   xladdmsg(o_XM_PUSH_BUTTON_GADGET_CLASS, ":ADD_CALLBACK",
  179.            FTAB_Xm_Push_Button_Widget_Class_Method_ADD_CALLBACK);
  180.   
  181.   xladdmsg(o_XM_PUSH_BUTTON_GADGET_CLASS, ":SET_CALLBACK",
  182.            FTAB_Xm_Push_Button_Widget_Class_Method_SET_CALLBACK);
  183. #endif                /* WINTERP_MOTIF_11 */
  184.  
  185. }
  186.